package org.raymond.iworks.study.example;

/*
import com.alibaba.csp.sentinel.Entry;
import com.alibaba.csp.sentinel.SphU;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.csp.sentinel.slots.block.RuleConstant;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
 */
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class SentinelCoreTest {
    private final static String resource = "HelloWorld";

    @BeforeAll
    public void initRule(){
        /*
        List<FlowRule> rules = new ArrayList<>();
        FlowRule rule = new FlowRule();
        rule.setResource(resource);
        rule.setGrade(RuleConstant.FLOW_GRADE_QPS);
        // set limit QPS
        rule.setCount(1);
        rules.add(rule);
        FlowRuleManager.loadRules(rules);
         */
    }

    @Test
    public void test1() {
        /*
        while(true){
            try (Entry entry = SphU.entry(resource)) {
                // biz logic begin
                System.out.println("Hello world!");
                // biz logic end
            } catch (BlockException e) {
                // flow control logic begin
                System.err.println(String.format("block: %s", e.getMessage()));
                // flow control logic end
            }
        }*/
    }

}
